import java.util.*;

public class LUR 
{
	ArrayList<Integer> lur = new ArrayList<Integer>();
	int PSC_PUB_Memory;
	int PSC_counter;
	
	LUR(int PUB_Memory)
	{
		PSC_PUB_Memory=PUB_Memory;
		PSC_counter=0;
	}
	
	public int run(int[] PUB_order,int length)
	{
		int i=0;
		for(;i<length;i++)
		{
			if(lur.isEmpty())
			{
				lur.add(PUB_order[i]);
			}else{
			if(lur.size()<PSC_PUB_Memory)
			{
				if(lur.contains(PUB_order[i]))
				{
					PSC_counter++;
					lur.remove(lur.indexOf(PUB_order[i]));
					lur.add(PUB_order[i]);
				}
				else
				{
					lur.add(PUB_order[i]);
				}
			}
			if(lur.size()==PSC_PUB_Memory)
			{
				if(lur.contains(PUB_order[i]))
				{
					PSC_counter++;
					lur.remove(lur.indexOf(PUB_order[i]));
					lur.add(PUB_order[i]);
				}
				else
				{
					lur.remove(0);
					lur.add(PUB_order[i]);
				}
			}
		}
		}
		return PSC_counter;
	}
}
